package com.baidu.location.demo

import android.graphics.BitmapFactory
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.qmuiteam.qmui.util.QMUIDisplayHelper
import com.service.HubService
import com.util.util

class ScreenActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        QMUIDisplayHelper.setFullScreen(this)
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_screen)
        var screenImage= findViewById<ImageView>(R.id.ScreenImage)
        HubService.hubConnection.on(
            "Counter",
            {
                this.runOnUiThread {
                    val it= util.unZip(it)
                    screenImage.setImageBitmap(BitmapFactory.decodeByteArray(it,0,it!!.size))
                }
            },
            ByteArray::class.java
        )
    }

    override fun onDestroy() {
        super.onDestroy()
        HubService.hubConnection.remove("Counter")
        QMUIDisplayHelper.cancelFullScreen(this)
        finish()
    }
}